//
//  UIImage+Extension.swift
//  Sina
//
//  Created by 王亮龙1 on 16/5/29.
//  Copyright © 2016年 lianglong. All rights reserved.
//

import UIKit

extension UIImage {
    
    class func snapShotCurrentWindow() -> UIImage {
        
        //获取window
        let window = UIApplication.sharedApplication().keyWindow!
        
        //开启图形上下文
        UIGraphicsBeginImageContextWithOptions(window.bounds.size, false, 0)
        
        //画图
        window.drawViewHierarchyInRect(window.bounds, afterScreenUpdates: false)
        
        //获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        //关闭图形上下文
        UIGraphicsEndImageContext()
        
        return image
    }
    
    
    
    
    
    
}


    